package scene.shape;
import scene.shape.geometry.Geometry;
import scene.shape.materials.Material;
import util.Matrix4f;


public class Shape {
	
	private Geometry geometry;
	private Material material;
	private Matrix4f transform, invTransform, invTransformTranspose;
	
	public Shape(Geometry geometry, Material material){
		this.geometry = geometry;
		this.material = material;
		geometry.setShape(this);
	}
	
	public Geometry getGeometry(){
		return geometry;
	}
	
	public Material getMaterial(){
		return material;
	}
	
	public void setTransformationMatrix(Matrix4f transformation){
		this.transform = transformation;
		this.invTransform = transformation.inverse();
		this.invTransformTranspose = invTransform.transpose();
	}
	
	public Matrix4f getTransform(){
		return transform;
	}
	
	public Matrix4f getInverseTransform(){
		return invTransform;
	}
	
	public Matrix4f getInverseTransformTranspose(){
		return invTransformTranspose;
	}
	
	public void transform(Matrix4f transformation){
		setTransformationMatrix(transformation);
	}
	
	public void addTransform(Matrix4f transformation){
		setTransformationMatrix(transform.multiply(transformation));
	}
}
